<template>
    <div class="view">
        <div class="page-statistics scrollRow">
            <template>
                <u-scrollRow :list="classList" label="sstClassName" match="classId" v-model="selClass" @change="classChange"></u-scrollRow>
            </template>
            <div class="m-con">
                <u-table class="statistics_table" :data="tableData">
                    <u-table-column type="index" width="35" className="ind"></u-table-column>
                    <u-table-column prop="name" label="姓名"></u-table-column>
                    <u-table-column prop="winningRate" label="胜率" width="107" className="rate">
                        <template slot-scope="scope">
                            <div>{{scope.row.winningRate}} %</div>
                        </template>
                    </u-table-column>
                    <u-table-column label="积分" width="72" className="score">
                        <template slot-scope="scope">
                            <div>{{scope.row.score}} 分</div>
                        </template>
                    </u-table-column>
                </u-table>
                <div class="vTips_empty" v-if="!tableData || !tableData.length">暂无数据</div>
            </div>
        </div>
    </div>
</template>

<script>
import * as api from '@/api/index';
export default {
    name: "grade",
    data(){
        return{
            userInfo: JSON.parse(localStorage.getItem("userInfo")),
            classList: [],
            selClass: {},

            tableData:[
            ],
        }
	},
    created(){
        this.getInit()
    },
	methods:{
        getInit(){
            const { classList } = this.userInfo
            this.classList = classList&&classList.length? classList: []
			var choseClassId = sessionStorage.getItem('choseClassId')
			this.selClass = choseClassId?this.classList.find(item => {return item.classId == choseClassId}):this.classList[0]
            this.getScoreOList()
        },
        async getScoreOList(){
            var data = {
                classId: this.selClass.classId,
                futureId: this.userInfo.futureId
            }
            var res = await api.getAnswerIngScoreByClass(data)
            if(res.resultCode == 1){
                this.tableData = res.value?res.value:[]
            }
        },
        
		// 选角
		classChange(){
			this.getScoreOList()
		},
			
	}
}
</script>